package com.ld.security.server.admin.modules.ge.util;

import com.ld.security.auth.shiro.util.LoginUtil;
import com.ld.security.common.core.exception.ApiException;
import com.ld.security.server.admin.modules.ge.entity.GeProjectUserRelEntity;
import com.ld.security.server.admin.modules.ge.service.IGeProjectUserRelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ProjectUtil {


   static IGeProjectUserRelService iGeProjectUserRelService;

    /**
     * 得到默认工程
     * @return
     */
    public static String getDefProectId(){
        String userId = LoginUtil.getUserId();
        GeProjectUserRelEntity geProjectUserRelEntity =  iGeProjectUserRelService.getDef(userId);
        if(geProjectUserRelEntity == null){
            ApiException.throw400("清选择默认工程");
        }
        return geProjectUserRelEntity.getProjectId();
    }


    public static IGeProjectUserRelService getiGeProjectUserRelService() {
        return iGeProjectUserRelService;
    }

    @Autowired
    public void setiGeProjectUserRelService(IGeProjectUserRelService iGeProjectUserRelService) {
        ProjectUtil.iGeProjectUserRelService = iGeProjectUserRelService;
    }
}
